/**
 * Copyright (c) Martijn Grootens (m.e.grootens@student.utwente.nl), 
 * University of Twente.
 * Created july 2012.
 *
 * This file is part of dbcleaner.
 * 
 * dbcleaner is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * dbcleaner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with dbcleaner.  If not, see <http://www.gnu.org/licenses/>.
 */

package dbcleaner.core.dbentries;

import java.util.*;
import dbcleaner.core.tags.*;
import dbcleaner.core.bibfields.*;

/**
 * Representation of the BibTeX library; In fact it is just an 
 * ArrayList of Entries.
 */
public class DataBase {
    
    // Name of the DataBase and its list of entries.
    private String name;
    private ArrayList<Entry> entries;
    
    /**
     * Constructor without DataBase name.
     */
    public DataBase () {
        this("no_name");
    }
    
    /**
     * Constructor with DataBase name.
     */
    public DataBase (String name) {
        set_name(name);
        entries = new ArrayList<Entry>();
    }
    
    /**
     * Get the number of Entries present in the DB.
     */
    public int get_size () {
        return entries.size();
    }
    
    /**
     * Set DataBase name.
     */
    public void set_name (String name) {
        this.name = name;
    }
    
    /**
     * Get DataBase name.
     */
    public String get_name () {
        return name;
    }
    
    /**
     * Get the list of Entries.
     */
    public ArrayList<Entry> get_entries () {
        return entries;
    }
    
    /**
     * Add a DataBase Entry.
     */
    public void add_entry (Entry e) {
        entries.add(e);
    }
    
    /**
     * Printable version of the DataBase. I.E. just a large string of the
     * printable version of all Entries.
     */
    public String toString () {
        String ss = "% Database: " + get_name() + "\n\n";
        
        for (Entry e : entries)
            ss += e;
        
        return ss;
    }
        

}